home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / LISTBOX / CHECKLB / EXAMPLE.ZIP / Unit1.pas < prev   
Pascal/Delphi Source File  |  1996-08-15  |  3KB  |  116 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, CheckLB;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button2: TButton;
  12.     FontDialog1: TFontDialog;
  13.     CheckListBox1: TCheckListBox;
  14.     GroupBox1: TGroupBox;
  15.     Edit1: TEdit;
  16.     Label1: TLabel;
  17.     CheckBox2: TCheckBox;
  18.     RadioButton1: TRadioButton;
  19.     RadioButton2: TRadioButton;
  20.     RadioButton3: TRadioButton;
  21.     Button1: TButton;
  22.     Button3: TButton;
  23.     Button4: TButton;
  24.     Button5: TButton;
  25.     procedure Button1Click(Sender: TObject);
  26.     procedure Button2Click(Sender: TObject);
  27.     procedure CheckListBox1Click(Sender: TObject);
  28.     procedure CheckBox2Click(Sender: TObject);
  29.     procedure Button3Click(Sender: TObject);
  30.     procedure Button4Click(Sender: TObject);
  31.     procedure Button5Click(Sender: TObject);
  32.   private
  33.     { DΘclarations privΘes }
  34.   public
  35.     { DΘclarations publiques }
  36.   end;
  37.  
  38. var
  39.   Form1: TForm1;
  40.  
  41. implementation
  42.  
  43. {$R *.DFM}
  44.  
  45. procedure TForm1.Button1Click(Sender: TObject);
  46. var
  47.   I: Integer;
  48. begin
  49.   with CheckListBox1 do begin
  50.     I := Items.Add(Edit1.Text);
  51.     if RadioButton1.Checked then
  52.       State[I] := cbChecked;
  53.     if RadioButton2.Checked then
  54.       State[I] := cbGrayed;
  55.     if RadioButton3.Checked then
  56.       State[I] := cbUnchecked;
  57.   end;
  58. end;
  59.  
  60. procedure TForm1.Button3Click(Sender: TObject);
  61. var
  62.   I: Integer;
  63. begin
  64.   with CheckListBox1 do begin
  65.     I := ItemIndex;
  66.     if I <> -1 then begin
  67.       Items[I] := Edit1.Text;
  68.       if RadioButton1.Checked then
  69.         State[I] := cbChecked;
  70.       if RadioButton2.Checked then
  71.         State[I] := cbGrayed;
  72.       if RadioButton3.Checked then
  73.         State[I] := cbUnchecked;
  74.     end;
  75.   end;
  76. end;
  77.  
  78. procedure TForm1.Button4Click(Sender: TObject);
  79. begin
  80.   with CheckListBox1 do
  81.     Items.Delete(ItemIndex);
  82. end;
  83.  
  84. procedure TForm1.Button2Click(Sender: TObject);
  85. begin
  86.   FontDialog1.Font := CheckListBox1.Font;
  87.   if FontDialog1.Execute then
  88.     CheckListBox1.Font := FontDialog1.Font;
  89. end;
  90.  
  91. procedure TForm1.CheckListBox1Click(Sender: TObject);
  92. begin
  93.   Edit1.Text := CheckListBox1.Items[CheckListBox1.ItemIndex];
  94.   case CheckListBox1.State[CheckListBox1.ItemIndex] of
  95.   cbChecked:
  96.     RadioButton1.Checked := True;
  97.   cbGrayed:
  98.     RadioButton2.Checked := True;
  99.   cbUnchecked:
  100.     RadioButton3.Checked := True;
  101.   end;
  102. end;
  103.  
  104. procedure TForm1.CheckBox2Click(Sender: TObject);
  105. begin
  106.   CheckListBox1.AllowGrayed := CheckBox2.Checked;
  107.   RadioButton2.Enabled := CheckBox2.Checked;
  108. end;
  109.  
  110. procedure TForm1.Button5Click(Sender: TObject);
  111. begin
  112.   Close;
  113. end;
  114.  
  115. end.
  116.